﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Hi_Baidu.Cache.CacheObject
{
    /// <summary>
    ///     缓存基类
    /// </summary>
    public abstract class Cache : ICache,IMetaData
    {
        /// <summary>
        ///     所有缓存的基类
        /// </summary>
        /// <param name="Key">缓存唯一标示</param>
        /// <param name="Value">缓存值</param>
        /// <param name="ExpridTime">缓存过期日期</param>
        public Cache(String Key, String Value, DateTime ExpridTime)
        {
            this.key = Key;
            this.value = Value;
            this.expridTime = ExpridTime;
            this.cacheTime = DateTime.Now;
        }

        private String value;
        private DateTime cacheTime;
        private DateTime expridTime;

        /// <summary>
        ///     缓存值
        /// </summary>
        public string Value
        {
            get { return value; }
            set { this.value = value; }
        }

        /// <summary>
        ///     缓存初始日期
        /// </summary>
        public DateTime CacheTime
        {
            get { return cacheTime; }
            set { cacheTime = value; }
        }

        /// <summary>
        ///     缓存过期日期
        /// </summary>
        public DateTime ExpridTime
        {
            get { return expridTime; }
            set { expridTime = value; }
        }

        #region ICache 成员

        public DateTime GetCacheTime()
        {
            return this.cacheTime;
        }

        public string GetValue()
        {
            return this.value;
        }

        public DateTime GetExpridTime()
        {
            return this.expridTime;
        }

        public abstract void Dispose();

        #endregion

        #region IMetaData 成员

        private String key;
        public string Key
        {
            get
            {
                return key;
            }
            set
            {
                key = value;
            }
        }

        #endregion
    }
}
